package com.itaq.cheetah.serviceA.controller;

import com.itaq.cheetah.serviceA.config.anno.VerifySign;
import com.itaq.cheetah.serviceA.model.dto.SsoRespDto;
import com.itaq.cheetah.serviceA.model.dto.ToServiceAReq;
import com.itaq.cheetah.serviceA.model.result.WrapperResult;
import com.itaq.cheetah.serviceA.utils.JsonUtils;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author cheetah
 * @date 2022/7/25
 */
@Slf4j
@RestController
@RequestMapping("/serviceA")
@AllArgsConstructor
public class ServiceAController {

    /**
     * @return
     */
    @PostMapping
    public WrapperResult<SsoRespDto> sso(@VerifySign ToServiceAReq req) {
        log.info("收到单点登录ServiceA的请求：{}", JsonUtils.toPrettyString(req));
        //同步用户信息

        //模拟登陆

        //返回拼接的url？token=xxx
        String url ="127.0.0.1:8081/index?token=xxx";
        SsoRespDto ssoRespDto = new SsoRespDto();
        ssoRespDto.setRedirectUrl(url);
        return WrapperResult.success(ssoRespDto);
    }
}
